package com.apptravel.dao;

import com.apptravel.entity.AirPort;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component("airPortDao")
public class AirPortDAOImpl extends MybatisDao implements AirPortDAO {

    public AirPortDAOImpl() {
        super();
    }

    public int deleteById(Long id) {
        AirPort _key = new AirPort();
        _key.setId(id);
        int rows = getSqlSession().delete("airport.deleteById", _key);
        return rows;
    }

    public int deleteByMap(Map<String,Object> params){
         return this.getSqlSession().delete("airport.deleteByMap",params);
    }

    public void insert(AirPort record) {
        getSqlSession().insert("airport.insert", record);
    }


    public AirPort selectById(Long id) {
        AirPort _key = new AirPort();
        _key.setId(id);
        AirPort record = (AirPort) getSqlSession().selectOne("airport.selectById", _key);
        return record;
    }



    public int updateById(AirPort record) {
        int rows = getSqlSession().update("airport.updateById", record);
        return rows;
    }

    public Page<AirPort> getList(Map<String,Object> params,int pageNo,int pageSize){
        params.put("page","");
        return this.selectPage("airport.selectByMap",params,pageNo,pageSize);
    }
}